package com.junjie.services.impl;

import com.junjie.dao.RConditionDao;
import com.junjie.entity.RCondition;
import com.junjie.services.RConditionService;
import com.junjie.utils.CommonParams;
import com.junjie.utils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RConditionServiceImpl implements RConditionService {

    @Autowired
    private RConditionDao rConditionDao;

    //万能查询接口
    @Override
    public List<RCondition> getRConditions(RCondition rCondition) {
        return rConditionDao.getRConditions(rCondition);
    }

    //根据 id rId status 来查询可以null
    @Override
    public RCondition getRConditionByIdRIdStatus(Integer id, Integer rId, Integer status) {
        return  rConditionDao.getRConditionByIdRIdStatus(id, rId, status);
    }

    //插入一条房间情况的信息
    @Override
    public CommonResult<Integer> insertRCondition(RCondition rCondition) {
        return new CommonResult<>(CommonParams.SUCCESS, "房间数据添加成功！", rConditionDao.insertRCondition(rCondition));
    }

    //修改一条数据的方法
    @Override
    public CommonResult<Integer> updateConditionById(RCondition rCondition) {
        return new CommonResult<>(CommonParams.SUCCESS, "修改数据成功！", rConditionDao.updateAndDeleteRCondition(rCondition));
    }

    //删除一条数据的方法
    @Override
    public CommonResult<Integer> deleteConditionById(Integer id) {
        RCondition rCondition = new RCondition();
        rCondition.setId(id);
        rCondition.setStatus(0);
        return new CommonResult<>(CommonParams.SUCCESS, "数据删除成功！", rConditionDao.updateAndDeleteRCondition(rCondition));
    }
}
